package com.cby.android.sample.model

import android.app.Application
import com.cby.android.library.base.BaseStateViewModel
import com.cby.android.sample.intent.ProjectIntent
import com.cby.android.sample.repository.WanAndroidApiImpl
import com.cby.android.sample.state.ProjectState

class ProjectViewModel(application: Application) : BaseStateViewModel<ProjectState, ProjectIntent>(application){

    private var wanAndroidApi = WanAndroidApiImpl()

    override fun dispatch(intent: ProjectIntent) {
        fetchDataWithStatus {
            val classifyResponse = wanAndroidApi.getProjectClassify()
            updateState(ProjectState(classify = classifyResponse.data))
            classifyResponse.isSuccess()
        }
    }
}